package com.nanhang.util;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Map;

public class JwtUtil {
	private static final String KEY = "nanhang";
	public static String createToken(Map<String,Object> map){
		return Jwts.builder()
				.setClaims(map)
				.signWith(SignatureAlgorithm.HS256, KEY)
				.compact();
	}
	public static Claims parseToken(String token){
		return Jwts.parser()
				.setSigningKey(KEY)
				.parseClaimsJws(token)
				.getBody();
	}
}
